import { Controller, Post, Body, Get, Param } from '@nestjs/common';
import { MessageService } from './message.service';

@Controller('message')
export class MessageController {
  constructor(private readonly messageService: MessageService) { }

  //查看用户会话列表
  @Get(':userId')
  findMyConversation(@Param() userDto: { userId: number }) {
    return this.messageService.findMyConversation(+userDto.userId)
  }

  /* 建立会话 */
  @Post('createSession')
  createSession(@Body() createSessionDto: { senderId: number, receiverId: number }) {
    return this.messageService.createSession(createSessionDto)
  }

  //处理消息
  @Post('sendMessage')
  handleMessage(@Body() sendMessageDto: { senderId: number, receiverId: number, conversationId: number, read: boolean, content: string }) {
    return this.messageService.handleMessage(sendMessageDto)
  }

  //查看未读消息
  @Post('unReadMessage')
  unReadMessage(@Body() userDto: { userId: number }) {
    return this.messageService.unReadCount(userDto.userId)
  }

}
